//
//  LaunchVC.swift
//  ImGuider X
//
//  Created by llt on 2018/9/12.
//  Copyright © 2018年 imguider. All rights reserved.
//

import UIKit

class LaunchVC: BaseVC {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) {

            [weak self] in
            guard let `self` = self else { return }

            self.login()
            
        }
    }
    
//    override func viewDidAppear(_ animated: Bool) {
//        
//        super.viewDidAppear(animated)
//        
//        self.showTestVersion()
//    }
    
    override var prefersStatusBarHidden: Bool {
        
        return true
    }
    
//    private func showFPSLabel() {
//
//        let label = YYFPSLabel()
//        label.backgroundColor = UIColor.black.withAlphaComponent(0.3)
//        label.frame = CGRect(x: 16, y: kNavigationBarHeight + 16, width: 0, height: 0)
//
//        label.sizeToFit()
//        label.layer.zPosition = .greatestFiniteMagnitude
//
//        UIApplication.shared.keyWindow?.addSubview(label)
//    }
    
    private func showTestVersion() {
        
        let label = UILabel()
        label.frame = CGRect(x: 0, y: kStatusBarHeight, width: kScreenWidth, height: 12)
        
        label.font = kFont12
        label.textColor = kThemeRedColor
        label.text = "版本号：\(kVersion ?? "") build\(kVersionBuild ?? "")"
        label.textAlignment = .center
        
        label.layer.zPosition = .greatestFiniteMagnitude
        
        UIApplication.shared.keyWindow?.addSubview(label)
    }
    
    private func login() {
        
        if AppManager.share.hasLoginOrJumpToLogin() {
            
            if let trips = TripManager.share.trips, trips.count > 0 {
                
                TripManager.share.reloadTripData()
                
                AppManager.share.HomePage()
                
            } else {
                
                AppManager.share.loginPage(true)
            }
        }  
    }

}
